<?php
    require_once('includes/common.inc.php');

    $pageName = "Purchase";
    $page = Pages::CreatePage($pageName);
    $page->SetVar("pageName", $pageName);

    $priceManager = new PriceManager();
    $basePrices = $priceManager->GetProductsPrices(PriceType::BASE);
    $retailPrices = $priceManager->GetProductsPrices(PriceType::RETAIL);

    $basePriceInfo = $basePrices[Product::CODEDRIVE][1];
    $priceInfo = $retailPrices[Product::CODEDRIVE][1];

    $specialOfferValidTill = $priceInfo->validTill;
    $isSpecialOffer = !empty($specialOfferValidTill);

    if ( $isSpecialOffer )
    {
        $specialOfferValidTill = DateUtils::FormatDateToSpecialOfferFull($specialOfferValidTill);
        $page->SetVar( "SPECIAL_OFFER_VALID_TILL", $specialOfferValidTill );
        $page->SetVar( "PRICE_DISCOUNTED", ProductPriceUtils::FormatPrice($priceInfo->volumePrice, $priceInfo->currency) );
        $page->SetVar( "PURCHASE_LINK", $priceInfo->purchaseUrl );
    }
    else
    {
        $page->SetVar( "PURCHASE_LINK", $basePriceInfo->purchaseUrl );
    }

    $page->SetVar( "PRICE_REGULAR", ProductPriceUtils::FormatPrice($basePriceInfo->volumePrice, $basePriceInfo->currency) );

    $productInfo = iSpringServices::GetProductInfo(Product::CODEDRIVE);
    $page->SetVar('VERSION', $productInfo->version);

    $page->Display();
?>